package outbound.container.dataObjects
{
	import common.utils.DateManager;
	import com.adobe.utils.StringUtil;	
	import mx.collections.ArrayCollection;
	
	public class ShippingContainerDO
	{
		public var INTERNAL_CONTAINER_NUM:Number = 0;
		public var CONTAINER_ID:String = "";
		public var WAREHOUSE:String = "";
		public var CONTAINER_TYPE:String = "";
		public var CONTAINER_CLASS:String = "";
		public var STATUS:Number = 0;
		public var PARENT:Number = 0;
		public var WEIGHT:Number = 0;
		public var WEIGHT_UM:String = "";
		public var VOLUME:Number = 0;
		public var LENGTH:Number = 0;
		public var WIDTH:Number = 0;
		public var HEIGHT:Number = 0;
		public var DIMENSION_UM:String = "";
		public var VOLUME_UM:String = "";
		public var VALUE:Number = 0;
		public var INTERNAL_SHIPMENT_NUM:Number = 0;
		public var INTERNAL_SHIPMENT_LINE_NUM:Number = 0;
		public var COMPANY:String = "";
		public var ITEM:String = "";
		public var QUANTITY:Number = 0;
		public var QUANTITY_UM:String = "";
		public var TRACKING_NUMBER:String = "";
		public var USER_DEF1:String = "";
		public var USER_DEF2:String = "";
		public var USER_DEF3:String = "";
		public var USER_DEF4:String = "";
		public var USER_DEF5:String = "";
		public var USER_DEF6:String = "";
		public var USER_DEF7:Number = 0;
		public var USER_DEF8:Number = 0;
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var GROUP_POSITION:String = "";
		public var INTERNAL_WAVE_NUM:Number = 0;
		public var CONTAINER_COUNT_NUMBER:Number = 0;
		public var CONTAINER_COUNT_TOTAL:Number = 0;
		public var GROUP_NUM:Number = 0;
		public var PARENT_CONTAINER_ID:String = "";
		public var INTERNAL_SHIP_ALLOC_NUM:Number = 0;
		public var TASK_CREATED:String = "";
		public var ATTRIBUTE_NUM:Number = 0;
		public var ORIGINAL_PICK_LOC:String = "";
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var SHIPMENT_ID:String = "";
		public var ITEM_DESC:String = "";
		public var GROUP_DESC:String = "";

		public function ShippingContainerDO()
		{
		}
		
		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
			GROUP_DESC = PARENT_CONTAINER_ID + " of " + SHIPMENT_ID;
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<SHIPPING_CONTAINER>
					<INTERNAL_SHIPMENT_NUM>{INTERNAL_SHIPMENT_NUM}</INTERNAL_SHIPMENT_NUM>
					<INTERNAL_SHIPMENT_LINE_NUM>{INTERNAL_SHIPMENT_LINE_NUM}</INTERNAL_SHIPMENT_LINE_NUM>
					<COMPANY>{COMPANY}</COMPANY>
					<ITEM>{ITEM}</ITEM>
					<QUANTITY>{QUANTITY}</QUANTITY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<TRACKING_NUMBER>{TRACKING_NUMBER}</TRACKING_NUMBER>
					<USER_DEF1>{USER_DEF1}</USER_DEF1>
					<USER_DEF2>{USER_DEF2}</USER_DEF2>
					<USER_DEF3>{USER_DEF3}</USER_DEF3>
					<USER_DEF4>{USER_DEF4}</USER_DEF4>
					<USER_DEF5>{USER_DEF5}</USER_DEF5>
					<USER_DEF6>{USER_DEF6}</USER_DEF6>
					<USER_DEF7>{USER_DEF7}</USER_DEF7>
					<USER_DEF8>{USER_DEF8}</USER_DEF8>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<GROUP_POSITION>{GROUP_POSITION}</GROUP_POSITION>
					<INTERNAL_WAVE_NUM>{INTERNAL_WAVE_NUM}</INTERNAL_WAVE_NUM>
					<CONTAINER_COUNT_NUMBER>{CONTAINER_COUNT_NUMBER}</CONTAINER_COUNT_NUMBER>
					<CONTAINER_COUNT_TOTAL>{CONTAINER_COUNT_TOTAL}</CONTAINER_COUNT_TOTAL>
					<GROUP_NUM>{GROUP_NUM}</GROUP_NUM>
					<PARENT_CONTAINER_ID>{PARENT_CONTAINER_ID}</PARENT_CONTAINER_ID>
					<INTERNAL_SHIP_ALLOC_NUM>{INTERNAL_SHIP_ALLOC_NUM}</INTERNAL_SHIP_ALLOC_NUM>
					<TASK_CREATED>{TASK_CREATED}</TASK_CREATED>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<ORIGINAL_PICK_LOC>{ORIGINAL_PICK_LOC}</ORIGINAL_PICK_LOC>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
				</SHIPPING_CONTAINER>;
			
			return xmlObj;
		}
		
		public static function getShippingConts(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var scDO:ShippingContainerDO = new ShippingContainerDO();
				scDO.Init(xml);
				ac.addItem(scDO);
			}
			return ac;
		}	
	}
}